Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to get link AABB from its collisions #2787

Open
wants to merge 7 commits into
base: gz-sim9
Choose a base branch
from

Conversation

gabrielfpacheco
Copy link
Contributor

@gabrielfpacheco gabrielfpacheco commented Feb 19, 2025

🎉 New feature

Summary

This PR adds AABB support to the Link API. It computes the overall link aligned bounding box (in local and world coordinates) by merging all collision bounding boxes obtained from their geometry shapes. Plus, it adds utility functions to transform AABB coordinates and calculate mesh AABB using utilities from gz::common::Mesh.

Test it

  • Checkout the appropriate gz-sim and sdformat branches
  • Build these packages
$ colcon build --packages-select sdformat15 gz-sim9 --merge-install
  • Run the following gz-sim9 tests:
$ ./build/gz-sim9/bin/UNIT_Util_TEST && ./build/gz-sim9/bin/INTEGRATION_link

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
* Following gazebosim#2353 (comment)
* This allows to use the ECM as cache if bounding box doesn't have to be
recomputed and is more suitable so that other systems can determine the
AABB if necessary (e.g. physics system if checks are enabled)

Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
@gabrielfpacheco
Copy link
Contributor Author

gabrielfpacheco commented Mar 10, 2025

@iche033, @scpeters, @ahcorde. Please, let me know if extra changes are required. If not, I will create a follow-up PR to add link AABB computation to the physics system update callback.

@iche033
Copy link
Contributor

iche033 commented Mar 10, 2025

@iche033, @scpeters, @ahcorde. Please, let me know if extra changes are required. If not, I will create a follow-up PR to add link AABB computation to the physics system update callback.

took a quick look at the logic for enabling and computing AxisAlignedBox in the Link class. I think overall the approach looks fine. I see that the AxisAlignedBox component is first initialized with results computed from SDF, then later the component will be updated with the value from the physics system. I'm curious to see how similar or different the two values are. If they are very different, it could be confusing to the users. We should have a test to verify that the values are similar within some reasonable tolerance.

This could be helpful if users want to explicetly compute the AABB from
the link SDF collision shapes. For instance, the Physics system can
fallback and use this method in case the selected engine does not support
AABB calculation.

Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
@gabrielfpacheco
Copy link
Contributor Author

gabrielfpacheco commented Mar 11, 2025

I'm curious to see how similar or different the two values are. If they are very different, it could be confusing to the users.

I chose to always initialize it using the SDF computation as a way to minimize inconsistencies, particularly before the physics system's first update call. This is especially relevant during the configuration of various plugins loaded from the SDF. For example, initializing it with math::AxisAlignedBox() would be ineffective for an external system performing AABB checks during its configuration step, as it would have to wait for the physics system to step at least once before obtaining a meaningful value (making plugins somewhat "dependents" of each other).

That said, if preferred, I can modify the initialization to use the default constructor or introduce a flag in the EnableBoundingBoxChecks method (e.g., initializeFromSdf = false) to give users control over this behavior. However, I’m concerned that this might add unnecessary complexity and be more confusing than providing an initial, yet meaningful, value upfront.

We should have a test to verify that the values are similar within some reasonable tolerance.

Agreed. I'm including this verification in the next PR I’m about to open to update the physics system. As the physics system will be able to use the SDF API as a fallback in case the engine does not support the AABB feature, I also added 0c79183 where ComputeAxisAlignedBox is made public.

Signed-off-by: Gabriel Pacheco <gabriel.fpacheco@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

Boundingbox on Link API
3 participants